<template>
	<div class="batch-cont" @click="hide">
		<!-- 列表头部组件 -->
		<custom-header :title="title" ref="customHeader" :hideRight="true"></custom-header>
		<!-- 搜索栏组件 -->
		<search-bar @send="getKeywords"></search-bar>
		<div class="list-cont" v-if="list.length">
			<div class="scroll-Y">
				<div class="list-item" v-for="item in list" :key="item.id">
					<div class="content">
						<div class="title">
							{{item.Title}}
						</div>
						<div class="creator">
							<span>创建人:</span>
							{{item.CreatorName}}
						</div>
						<div class="created_time">
							<span>创建时间: </span>
							{{item.DateCreated}}
						</div>
					</div>
					<div class="enter" @click="goTestList(item)">
						进入
					</div>
				</div>
			</div>
			<div class="no-more">没有更多了...</div>
		</div>

		<no-data v-else></no-data>
	</div>
</template>

<script>
import customHeader from "@/components/custom-header.vue";
import searchBar from "@/components/search-bar.vue";
import noData from "@/components/no-data.vue";
export default {
	components: {
		searchBar,
		customHeader,
		noData,
	},
	data() {
		return {
			title: "批次列表",
			list: [],
			scrollTop: 0,
			keywords: "",
		};
	},
	created() {
		this.getBatchList();
	},
	methods: {
		getKeywords(text) {
			window.console.log(text);
			this.getBatchList(text);
		},
		getBatchList(e) {
			this.$toast.loading({
				message: "加载中...",
				forbidClick: true,
				duration: 0,
			});
			this.$api.batch
				.batchList({
					title: e || "",
					page: 1,
					pageSize: 10,
				})
				.then((res) => {
					window.console.log(res);
					if (res.list && res.list.length) {
						this.list = res.list;
					} else {
						this.list = [];
					}
				})
				.finally(() => {
					this.$toast.clear();
				});
		},
		goTestList(row) {
			this.$router.push({
				name: "testList",
				params: {},
			});
			localStorage.setItem('activeBatchId',row.Id)
		},
		hide() {
			this.$refs.customHeader.hide();
			window.console.log("隐藏");
		},
	},
};
</script>

<style lang="less" scoped>
@import "index.less";
</style>
